package com.lenovo.smarttraffic.ui.fragment;

import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.lenovo.smarttraffic.Constant;
import com.lenovo.smarttraffic.R;

import static com.lenovo.smarttraffic.InitApp.IS_IPSET;


/**
 * @author Amoly
 * @date 2019/4/11.
 * description：主页面
 */
public class MainContentFragment extends BaseFragment {
    private static MainContentFragment instance = null;
    private Button btnSearchEnv;

    public static MainContentFragment getInstance() {
        if (instance == null) {
            instance = new MainContentFragment();
        }
        return instance;
    }


    @Override
    protected View getSuccessView() {
        View view = View.inflate(getActivity(), R.layout.fragment_home, null);
        setListener(view);
        return view;
    }

    private void setListener(View view) {
        btnSearchEnv = (Button) view.findViewById(R.id.btn_searchEnv);

        btnSearchEnv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (IS_IPSET){
                    Toast.makeText(mActivity, "查询成功！", Toast.LENGTH_SHORT).show();
                }else {
                    Toast.makeText(mActivity, "未设置ip", Toast.LENGTH_SHORT).show();
                }
            }
        });

    }

    @Override
    protected Object requestData() {
        return Constant.STATE_SUCCEED;
    }

    @Override
    public void onClick(View view) {

    }

    @Override
    public void onDestroy() {
        if (instance != null) {
            instance = null;
        }
        super.onDestroy();
    }


}
